<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form>
			<p:growl></p:growl>
			<h:panelGrid style="width: 100%;">
            <h:outputText value="#{msg['servicegroups.label.heading']}" styleClass="outputTextTitle" />
				
				<h:panelGrid columns="3" style="">
				<h:outputLabel value="Module " />
				<h:outputLabel value=" : " />				
				<p:selectOneMenu value="#{serviceGroupsBean.selectedModuleId}" styleClass="adminSelectOneMenuWidth">
				<f:selectItem itemLabel="Select a module" itemValue=""/>
                    	<f:selectItems value="#{serviceGroupsBean.modulesMap}" />
                    	<p:ajax event="change" listener="#{serviceGroupsBean.moduleChangeListener}" update="@form"/>
				</p:selectOneMenu>
					<h:outputLabel value="Service Group "  />
				<h:outputLabel value=" : " />
				<p:selectOneMenu value="#{serviceGroupsBean.selectedServiceGroupId}" styleClass="adminSelectOneMenuWidth">				
				<f:selectItem itemLabel="Select a service group" itemValue=""/>
                    	<f:selectItems value="#{serviceGroupsBean.serviceGroupsMap}" />
                    	<p:ajax event="change" listener="#{serviceGroupsBean.serviceGroupChangeListener}" update="@form"/>
				</p:selectOneMenu>
				</h:panelGrid>
				
				<h:outputLabel value="Details for #{rolesBean.selectedRole.displayName} service group" styleClass="outputTextSubTitle" rendered="#{serviceGroupsBean.detailsForServiceGroup}"/>
				
				<h:panelGrid columns="1" style="border: 1px solid #d9d9d9; width: 100%" rendered="#{serviceGroupsBean.detailsForServiceGroup}">
				
				<h:panelGrid columns="3"  cellspacing="10">
				<h:outputLabel value="Service Group Name "  />
				<h:outputLabel value=" : " />				
				<p:inplace>  
                       <p:inputText value="#{serviceGroupsBean.selectedServiceGroup.servicegroupName}" />  
                </p:inplace>
				
				<h:outputLabel value="Display Name "  />
				<h:outputLabel value=" : " />				
				<p:inplace>  
                       <p:inputText value="#{serviceGroupsBean.selectedServiceGroup.displayName}" />  
                </p:inplace>
				
				<h:outputLabel value="Description "  />
				<h:outputLabel value=" : " />				
				<p:inplace>  
                       <p:inputTextarea value="#{serviceGroupsBean.selectedServiceGroup.description}" />  
                </p:inplace>
				</h:panelGrid>

 				<h:outputLabel value="Services" styleClass="outputTextSubTitle" />
				<p:dataTable id="serviceGroupTable" value="#{serviceGroupsBean.services}" var="row"
						>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Service Name" />
							</f:facet>
							<h:outputText value="#{row.serviceName}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Display Name" />
							</f:facet>
							<h:outputText value="#{row.displayName}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Description" />
							</f:facet>
							<h:outputText value="#{row.description}" />
						</p:column>
						<p:column style="width: 40px; text-align: center">
							<f:facet name="header">
								<h:outputText value="Assign" />
							</f:facet>
							<f:ajax render="serviceGroupTable">
							<p:selectBooleanCheckbox value="#{row.checked}" />
							</f:ajax>
						</p:column>

				</p:dataTable>
				<p:commandButton value="Save" action="#{serviceGroupsBean.updateServiceGroupAction}" update="@form" />
				</h:panelGrid>
			
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>

